import ctypes





# 加载DLL
# dll = ctypes.cdll.LoadLibrary('lib\\libcmake_dll_helloworld.dll')
# dll = ctypes.windll.LoadLibrary('lib\\libcmake_dll_helloworld.dll')
# os.add_dll_directory("D:\\code\\other\\Window_Vscode_Cmake_CPP_Helloworld\\test6\\lib")
# C:\msys64\mingw64\bin\libgcc_s_seh-1.dll

ctypes.cdll.LoadLibrary('lib\\libwinpthread-1.dll')
ctypes.cdll.LoadLibrary('lib\\libgcc_s_seh-1.dll')
ctypes.cdll.LoadLibrary('lib\\libstdc++-6.dll')
dll = ctypes.cdll.LoadLibrary('lib\\libcmake_dll_helloworld.dll')
# dll = ctypes.WinDll('lib\\libcmake_dll_helloworld.dll')

# 调用DLL中的HelloWorld函数
# dll.create_HelloWorldClass.restype = 


dll.create_HelloWorldClass.argtypes = [ctypes.c_int]
dll.create_HelloWorldClass.restype = ctypes.c_void_p
pobj = dll.create_HelloWorldClass(10)

dll.HelloWorldClass_say_hello.argtypes = [ctypes.c_void_p]
# dll.HelloWorldClass_say_hello.restype = ctypes.c_void_p

dll.HelloWorldClass_say_hello(pobj)

dll.HelloWorldClass_set_mnvar1.argtypes=[ctypes.c_void_p, ctypes.c_int]
# dll.HelloWorldClass_set_mnvar1.restype = ctypes.c_void_p
dll.HelloWorldClass_set_mnvar1(pobj, 19900)


dll.HelloWorldClass_get_mnvar1.argtypes=[ctypes.c_void_p]
dll.HelloWorldClass_get_mnvar1.restype=ctypes.c_int
var1 = dll.HelloWorldClass_get_mnvar1(pobj)
print(var1)

dll.HelloWorldClass_get_mfvar2.argtypes=[ctypes.c_void_p]
dll.HelloWorldClass_get_mfvar2.restype=ctypes.c_float
var2 = dll.HelloWorldClass_get_mfvar2(pobj)
print(var2)


# dll.SayHelloWorld.restype = None  # 设置返回类型
# dll.SayHelloWorld.argtypes = []   # 设置参数类型，这里是无参数


# # 调用函数
# # dll.SayHelloWorld()


# dll.CPPFun.restype = None  # 设置返回类型
# dll.CPPFun.argtypes = []   # 设置参数类型，这里是无参数
# dll.CPPFun()
